Exemple 3: UV spectroscopy

In [15]:
using msJ

The mzXML are storred in a folder. We set the current directory to this folder.

In [12]:
cd("/Volumes/LACIE/DESIRS_nov_2015/Mode_negatif/BPTI_4.5_7.5eV/")

The readdir() function lists the files and directories and returns a vector of strings.

In [13]:
readdir()
Out[13]:
17-element Array{String,1}:
 "BPTI_4-5_7-5eV01.mzXML"
 "BPTI_4-5_7-5eV02.mzXML"
 "BPTI_4-5_7-5eV03.mzXML"
 "BPTI_4-5_7-5eV04.mzXML"
 "BPTI_4-5_7-5eV05.mzXML"
 "BPTI_4-5_7-5eV06.mzXML"
 "BPTI_4-5_7-5eV07.mzXML"
 "BPTI_4-5_7-5eV08.mzXML"
 "BPTI_4-5_7-5eV09.mzXML"
 "BPTI_4-5_7-5eV10.mzXML"
 "BPTI_4-5_7-5eV11.mzXML"
 "BPTI_4-5_7-5eV12.mzXML"
 "BPTI_4-5_7-5eV13.mzXML"
 "BPTI_4-5_7-5eV14.mzXML"
 "BPTI_4-5_7-5eV15.mzXML"
 "BPTI_4-5_7-5eV16.mzXML"
 "TempSequence.sld"      

Using the filter function, the list of files can be limited to those containg the .mzXML

In [16]:
files = filter(x->occursin(".mzXML",x), readdir())
Out[16]:
16-element Array{String,1}:
 "BPTI_4-5_7-5eV01.mzXML"
 "BPTI_4-5_7-5eV02.mzXML"
 "BPTI_4-5_7-5eV03.mzXML"
 "BPTI_4-5_7-5eV04.mzXML"
 "BPTI_4-5_7-5eV05.mzXML"
 "BPTI_4-5_7-5eV06.mzXML"
 "BPTI_4-5_7-5eV07.mzXML"
 "BPTI_4-5_7-5eV08.mzXML"
 "BPTI_4-5_7-5eV09.mzXML"
 "BPTI_4-5_7-5eV10.mzXML"
 "BPTI_4-5_7-5eV11.mzXML"
 "BPTI_4-5_7-5eV12.mzXML"
 "BPTI_4-5_7-5eV13.mzXML"
 "BPTI_4-5_7-5eV14.mzXML"
 "BPTI_4-5_7-5eV15.mzXML"
 "BPTI_4-5_7-5eV16.mzXML"

We can look into the files using the info function

In [56]:
info(files[1])
Out[56]:
5-element Array{String,1}:
 "502 scans"       
 "MS2- 929  CID"   
 "MS2- 1084  CID"  
 "MS2- 1301  CID"  
 "MS2- 1626.5  CID"
In [ ]:

In [27]:
s = load(files[12]);
In [96]:
a = average(s, msJ.Precursor(929))
Out[96]:
msJ.MSscans([1, 2, 3, 4, 5, 6, 7, 8, 9, 10  …  126, 127, 128, 129, 130, 131, 132, 133, 134, 135], [0.1621, 1.0123, 1.8751, 2.7667, 3.6563, 4.5458, 5.438, 6.3446, 7.2342, 8.1257  …  111.453, 112.345, 113.234, 114.125, 115.003, 115.893, 116.799, 117.69, 118.58, 119.445], 1.0027483360000003e7, [255.0833282470703, 255.1666717529297, 255.25, 255.3333282470703, 255.4166717529297, 255.5, 255.5833282470703, 255.6666717529297, 255.75, 255.8333282470703  …  1999.25, 1999.3333740234375, 1999.416748046875, 1999.5, 1999.5833740234375, 1999.666748046875, 1999.75, 1999.8333740234375, 1999.916748046875, 2000.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0  …  1.220844076600501e-19, 7.435252093752792e-19, 2.3448499350715055e-19, 2.215733168715774e-20, 0.0, 2.624634390107953e-23, 1.679762742592886e-23, 4.9818453540717987e-23, 3.1915597720794143e-23, 5.7529109409914876e-24], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2  …  2, 2, 2, 2, 2, 2, 2, 2, 2, 2], 928.8333740234375, 7586.449010778356, [929.0, 929.0, 929.0, 929.0, 929.0, 929.0, 929.0, 929.0, 929.0, 929.0  …  929.0, 929.0, 929.0, 929.0, 929.0, 929.0, 929.0, 929.0, 929.0, 929.0], ["-", "-", "-", "-", "-", "-", "-", "-", "-", "-"  …  "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"], ["CID", "CID", "CID", "CID", "CID", "CID", "CID", "CID", "CID", "CID"  …  "CID", "CID", "CID", "CID", "CID", "CID", "CID", "CID", "CID", "CID"], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0  …  0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0  …  1.4184926330969135e-18, 8.511593474359544e-18, 2.724469424366245e-18, 2.5744492986226753e-19, 0.0, 3.049549584831409e-22, 1.9517079382925834e-22, 5.45429483473173e-22, 3.7082573537067337e-22, 6.684278480002341e-23])
In [100]:
c = centroid(a, method=msJ.TBPD(:gauss, 1000., 0.05))
#c = centroid(a, method=msJ.SNRA(0.07, 100))
Out[100]:
msJ.MSscans([1, 2, 3, 4, 5, 6, 7, 8, 9, 10  …  126, 127, 128, 129, 130, 131, 132, 133, 134, 135], [0.1621, 1.0123, 1.8751, 2.7667, 3.6563, 4.5458, 5.438, 6.3446, 7.2342, 8.1257  …  111.453, 112.345, 113.234, 114.125, 115.003, 115.893, 116.799, 117.69, 118.58, 119.445], 8303.693347139706, [921.3333740234375, 921.75, 924.5, 926.8333740234375, 927.1666870117188, 928.8333740234375, 930.25, 930.4166870117188, 931.5, 931.9166870117188, 1076.5833740234375, 1083.75, 1084.0833740234375, 1084.5, 1085.0833740234375, 1085.5, 1291.8333740234375, 1300.5, 1301.0, 1301.166748046875], [5.374599118834866, 6.598530633970184, 5.010893137201925, 60.939715346142094, 50.80504979425005, 7586.449010778356, 139.04493181440563, 126.14848631631443, 6.21308653623783, 4.684101717063503, 7.195634873767693, 133.96686415495694, 97.74886915418833, 33.473884389577066, 6.114870097140212, 4.4891847975498695, 5.445267765691911, 12.65502632667259, 6.911908706385296, 4.423431680999449], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2  …  2, 2, 2, 2, 2, 2, 2, 2, 2, 2], 928.8333740234375, 7586.449010778356, [929.0, 929.0, 929.0, 929.0, 929.0, 929.0, 929.0, 929.0, 929.0, 929.0  …  929.0, 929.0, 929.0, 929.0, 929.0, 929.0, 929.0, 929.0, 929.0, 929.0], ["-", "-", "-", "-", "-", "-", "-", "-", "-", "-"  …  "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"], ["CID", "CID", "CID", "CID", "CID", "CID", "CID", "CID", "CID", "CID"  …  "CID", "CID", "CID", "CID", "CID", "CID", "CID", "CID", "CID", "CID"], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0  …  0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [13.199063601964548, 15.222402106008019, 12.211297538216407, 45.6718629824978, 39.59272959550787, 1882.9744972387261, 67.63560827773267, 63.17133537008309, 10.60313601953229, 8.162798369034936, 13.192020871583912, 72.30443312055041, 51.18139523649448, 29.918865011534187, 12.195414260476388, 10.925568596541732, 11.789244226474834, 17.48404262264676, 12.197850348567298, 8.252452329935565])
In [84]:
length(c.mz)
Out[84]:
7
In [109]:
using Plots
plotly()
Out[109]:
Plots.PlotlyBackend()
In [54]:

Out[54]:
msJ.MSscans
In [110]:
plot(a)
Out[110]:
Plots.jl
In [111]:
plot(a, method = :absolute)
scatter!(c, method = :absolute)
Out[111]:
Plots.jl
In [112]:
plotlyjs()
Out[112]:
Plots.PlotlyJSBackend()
In [113]:
plot(a, method = :absolute)
scatter!(c, method = :absolute)
Out[113]:
Plots.jl
In [ ]:

We will loop over the file list

In [ ]:
for f in files
In [ ]:

We will use the same data set as in Example 1

In [2]:
using HTTP

data = download("https://raw.githubusercontent.com/ajgiuliani/msJ.jl/master/test/test.mzXML", 
                "~/Downloads/test.mzXML") ;

Now, using the info function of the msJpackage, we will see what is inside the file

In [3]:
info(data)
Out[3]:
4-element Array{String,1}:
 "6 scans"                
 "MS1+"                   
 "MS2+ 1255.5  CID(CE=18)"
 "MS3+ 902.33  PQD(CE=35)"
In [4]:
s = load(data) ;

Getting chromatograms is straightforward using the chromatogram method. We load the entiere chromatogram like this:

In [5]:
full_TIC = chromatogram(s)
Out[5]:
msJ.Chromatogram([0.1384, 0.7307, 2.1379, 3.7578, 4.3442, 5.7689], [5.08195e6, 9727.2, 11.3032, 4.8084e6, 12203.5, 4.84455], 5.08195e6)

We may also filter the data to first MS level:

In [6]:
MS1_TIC = chromatogram(s, msJ.Level(1))
Out[6]:
msJ.Chromatogram([0.1384, 3.7578], [5.08195e6, 4.8084e6], 5.08195e6)

Or we may get only the mass spectrometry data which have been aquirred under CID conditions:

In [7]:
CID_TIC = chromatogram(s, msJ.Activation_Method("CID"))
Out[7]:
msJ.Chromatogram([0.7307, 4.3442], [9727.2, 12203.5], 12203.5)

We can also extract the chromatogram for a specific precursor ion:

In [8]:
mz902_TIC = chromatogram(s, msJ.Precursor(902.33))
Out[8]:
msJ.Chromatogram([2.1379, 5.7689], [11.3032, 4.84455], 11.3032)

Let plot the chromatograms, using theGR backend:

In [9]:
using Plots
gr()
Out[9]:
Plots.GRBackend()

A recipe has also been defined for chromatogram data.

In [10]:
gr()
p1 = plot(full_TIC, label = "full tic")
p2 = plot(MS1_TIC, label = " MS1_TIC")
p3 = plot(CID_TIC, label = "CID_TIC")
p4 = plot(mz902_TIC, label = "mz902_TIC")

p = plot(p1, p2, p3, p4, layout = (4,1), size = (500,500))
Out[10]:
0.00 0.02 0.04 0.06 0.08 0 25 50 75 100 time (mins) Intensity (%) full tic 0.01 0.02 0.03 0.04 0.05 0.06 0 25 50 75 100 time (mins) Intensity (%) MS1_TIC 0.02 0.03 0.04 0.05 0.06 0.07 0 25 50 75 100 time (mins) Intensity (%) CID_TIC 0.04 0.05 0.06 0.07 0.08 0.09 0 25 50 75 100 time (mins) Intensity (%) mz902_TIC

Plots made using GR() may be saved to a file:

In [11]:
savefig(p, "~/Downloads/temp.png")

Average mass spectra may be obtained using the proper msfilter functions:

In [12]:
ms1 = msJ.average(s, msJ.Level(1))                              # MS1 scans
ms2_CID = msJ.average(s, msJ.Activation_Method("CID"))          # CID scans
ms2_PQD = msJ.average(s, msJ.Activation_Method("PQD"))          # PQD scans
ms2_1255 = msJ.average(s, msJ.Precursor(1255.5));               # Precursor m/z = 1255.5 scans

Mass spectra may be plotted the same way as chromatograms:

In [13]:
plotly()
p5 = plot(ms1, label = "MS", color = :blue)
p6 = plot(ms2_CID, label = "CID", color = :green)
p7 = plot(ms2_PQD, label = "PQD", color = :purple)
p8 = plot(ms2_1255, label = "mz 1255", color = :orange)
plot(p5, p6, p7, p8, layout = (4,1), size = (800,600))
Out[13]:
Plots.jl